import { MockMethod } from 'vite-plugin-mock';
import { resultSuccess } from '../_util';

const menuList = (() => {
  const result: any[] = [];
  for (let index = 1; index < 3; index++) {
    result.push({
      categoryId: `${index + 1}`,
      categoryName: ['商品', '服饰', '汽车'][index],
      image: '@image("1200x800", "#fa541c")',
      orderNo: index + 1,
      'status|1': ['0', '1'],
      children: (() => {
        const children: any[] = [];
        for (let j = 1; j < 4; j++) {
          children.push({
            categoryId: index * 10 + j + 1,
            categoryName: ['菜单1', '菜单2', '菜单3', '菜单4'][j],
            orderNo: j + 1,
            'status|1': ['0', '1'],
            children: (() => {
              const children: any[] = [];
              for (let k = 1; k < 1; k++) {
                children.push({
                  categoryId: index * 100 + j * 10 + k + 1,
                  categoryName: '按钮' + (j + 1) + '-' + (k + 1),
                  orderNo: j + 1,
                  'status|1': ['0', '1'],
                  children: [],
                });
              }
              return children;
            })(),
          });
        }
        return children;
      })(),
    });
  }
  return result;
})();
const menuParentList = (() => {
  const result: any[] = [];
  for (let index = 1; index < 3; index++) {
    result.push({
      categoryId: `${index}`,
      categoryName: ['商品', '服饰', '汽车'][index],
      children: (() => {
        const children: any[] = [];
        for (let j = 0; j < 4; j++) {
          children.push({
            categoryId: index * 10 + j,
            categoryName: ['菜单1', '菜单2', '菜单3', '菜单4'][j],
            children: [],
          });
        }
        return children;
      })(),
    });
  }
  return result;
})();
export default [
  //产品分类
  {
    url: '/mock-api/v1/goods/category/page',
    timeout: 100,
    method: 'post',
    response: () => {
      return resultSuccess({ list: menuList, total: 10 });
    },
  },
  {
    url: '/mock-api/v1/goods/category/plist',
    timeout: 100,
    method: 'post',
    response: () => {
      return resultSuccess(menuParentList);
    },
  },
  {
    url: '/mock-api/v1/goods/category/list',
    timeout: 100,
    method: 'post',
    response: () => {
      return resultSuccess(menuList);
    },
  },
] as MockMethod[];
